#include <cstdint>
#include <iostream>

template <typename T> T sum(size_t s, T *array) {
  T res = 0;
  for (size_t i = 0; i < s; i++) {
    res += array[i];
  }
  return res;
}

template <> std::string sum(size_t s, std::string *array) {
  std::string res;
  for (size_t i = 0; i < s; i++) {
    res.append(array[i]);
  }
  return res;
}

int main() {
  int32_t array[] = {1, 2, 3, 4};
  int32_t res = sum<int32_t>(4, array);
  std::string str[] = {"123", "345"};
  std::string str_res = sum<std::string>(2, str);

  std::cout << res << std::endl;
  std::cout << str_res << std::endl;
}
